<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ include file="/common/init.jsp"%>
<html>
<head>
<title>澳斯浪廷会员平台</title>
<link href="<c:url value='/resources/css/css.css'/>" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<c:url value='/resources/js/jquery-1.7.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/resources/js/validate.js'/>"></script>
</head>
<body leftmargin="0">
	<div class="main">
		<div class="width_l">
			<iframe src="menu.action" frameborder="0" width="250" height="100%" class="menu"></iframe>
		</div>
		<div class="right">
			<div class="width_r">
				<div class="menu_r">
					<ul>
						<li><a href="index.action">首页</a></li>
						<li><a href="information.action">消息</a></li>
						<li><a href="notice.action">公告中心</a></li>
						<li><a href="news.action">新闻中心</a></li>
						<li><a href="inbox.action">收件箱</a></li>
						<li><a href="tomail.action">写邮件</a></li>
						<li><a href="sent.action">已发送</a></li>
						<li><a href="${ctx}/exit.action">安全退出</a></li> 
					</ul>
				</div>
				<div class="news_top">
					<img src="<c:url value='/resources/images/top.jpg'/>" />
				</div>
				<form id="othermember" name="othermember" method="post">
				<input type="hidden" name="registerType" id="registerType" value="other"/>
				<div class="news">
					<h4>注册新单</h4>
					<div class="zhxx">
						<div class="zh_tit">账户信息</div>
						<table width="840" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="74">会员帐户：</td>
								<td width="136"><input name="user.userAccount" type="text" class="text" size="16" value="${randStr}" id="userAccount" readonly/></td>
								<td width="72"><img
									src="<c:url value='/resources/images/huan.jpg'/>" id="changeName"/></td>
								<td width="66">推荐人：</td>
								<td width="154"><input name="user.recommendId" type="text" class="text" size="16" value="${user.userAccount}" id="recommendId" readonly="readonly"/></td>
								<td width="62">安置人：</td>
								<td width="276"><input name="user.parentId" type="text" class="text" size="16" id="parentId" value="${parentId}" readonly="readonly"/></td>
							</tr>
						</table>
						<table width="840" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="74">市场部门：</td>
								<td width="136">
									<select name="user.location" id="location">
										<c:forEach var="loc" items="${locationList}">
										 	<option value="${loc.code }" <c:if test="${loc.code eq location}">selected</c:if>>${loc.name }</option>
										</c:forEach>
									</select>
								</td>
								<td width="66">会员级别：</td>
								<td width="154">
								<select name="user.level">
									<c:forEach var="level" items="${levelList}">
									 	<option value="${level.code }">${level.name }</option>
									</c:forEach>
								</select>
								</td>
								<td width="82">报单类型：</td>
								<td width="256">
									<select name="user.enterType" id="entertype">
									<c:forEach var="level" items="${enterTypelList}">
									 	<option value="${level.code }">${level.name }</option>
									</c:forEach>
								</select>
								</td>
							
							</tr>
						</table>
					</div>
					<div class="zhxx">
						<div class="zh_tit">设置密码</div>

						<div class="mima">
							<div class="mima_1">
								<table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td width="101">设置登陆密码</td>
										<td width="149">&nbsp;</td>
									</tr>
									<tr>
										<td style="text-align: right;">登录密码：</td>
										<td><input name="user.firstPwd" type="password" class="text" size="18" id="firstPwd"/></td>
									</tr>
									<tr>
										<td style="text-align: right;">确认登录密码：</td>
										<td><input name="firstPwd2" type="password" class="text" size="18" id="firstPwd2"/></td>
									</tr>
								</table>
							</div>
							<div class="mima_2">
								<table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td width="101">设置二级密码</td>
										<td width="149">&nbsp;</td>
									</tr>
									<tr>
										<td style="text-align: right;">二级密码：</td>
										<td><input name="user.secondPwd" type="password" class="text" size="18" id="secondPwd"/></td>
									</tr>
									<tr>
										<td style="text-align: right;">确认二级密码：</td>
										<td><input name="secondPwd2" type="password" class="text" size="18" id="secondPwd2"/></td>
									</tr>
								</table>
							</div>
							<div class="mima_3">
								<table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
									<tr>
										<td width="101">设置三级密码</td>
										<td width="149">&nbsp;</td>
									</tr>
									<tr>
										<td style="text-align: right;">三级密码：</td>
										<td><input name="user.thirdPwd" type="password" class="text" size="18" id="thirdPwd"/></td>
									</tr>
									<tr>
										<td style="text-align: right;">确认三级密码：</td>
										<td><input name="thirdPwd2" type="password" class="text" size="18" id="thirdPwd2"/></td>
									</tr>
								</table>
							</div>
						</div>
					</div>
					<div class="zhxx">
						<div class="zh_tit">银行账户信息</div>
						<table width="840" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="65" style="text-align: right;">开户行：</td>
								<td width="451"><input name="bankType" type="radio" value="1" checked="checked"/> 
									<select	name="bankName1">
										<c:forEach var="bank" items="${bankList}">
											<option value="${bank.name }">${bank.name }</option>
										</c:forEach>
									</select> 
									<input name="bankType" type="radio" value="2" /> 自定义：
									<input name="bankName2" class="text" type="text" size="16" value="" id="bankName2"/>
								</td>
								<td width="70" style="text-align: right;">分支行：</td>
								<td width="254"><input name="userBank.subBranch" type="text" class="text" size="30" id="subBranch"/></td>
							</tr>
							<tr>
								<td style="text-align: right;">国家：</td>
								<td>
									<select name="userBank.bankCountry" id="bankCountry" class="text">
										<option value="">--请选择国家--</option>
										<c:forEach var="loc" items="${listCountry}">
											<option value="${loc.id.f3}">${loc.id.f3 }</option>
										</c:forEach>
									</select>
									<!-- <input name="bankCountry" class="text" type="text" size="30" id="bankCountry"/> -->
								</td>
								<td style="text-align: right;">省市：</td>
								<td>
									<select name="userBank.bankProvince" id="bankProvince" class="text">
										<option value="">--请选择省市--</option>
									</select>
									<!-- <input name="bankProvince" class="text" type="text" size="30" id="bankProvince"/> -->
								</td>
							</tr>
							<tr>
								<td style="text-align: right;">开户名：</td>
								<td>
									<input name="userBank.bankUser" class="text" type="text" size="15" id="bankUser"/><font color="red"> (确定之后不能修改)</font>
								</td>
								<td style="text-align: right;">银行账号：</td>
								<td>
									<input name="userBank.bankCard" class="text" type="text" size="30" id="bankCard"/>
								</td>
							</tr>
						</table>
					</div>
					<div class="tijiao" id="submitOther">
						<img src="<c:url value='/resources/images/tijiao.jpg'/>" onclick="doSave();" id="other"/>
					</div>
				</div>
				</form>
				<div class="news_down">
					<img src="<c:url value='/resources/images/down.jpg'/>" />
				</div>
			</div>
		</div>
	</div>
</body>
</html>
<script type="text/javascript">
$(function(){
	$("#changeName").click(function(){
		$.ajax({
			type: 'POST',
			url: "${ctx}/getaccount.action",
			dataType: "html",
			success: function(data,status){
				//alert(data);
				if($.trim(data)!=''){
					$("#userAccount").val(data);
				}
			},
			error: function(data,status,e){
				alert(e.name);
			}
		});
	});
	$("#entertype").change(function(){
		var entertype = $("#entertype").val();
		var parentId = $("#parentId").val();
		var location = $("#location").val();
		if('2' == entertype){//追加
			window.location.href= "${ctx}/myself.action?parentId="+parentId+"&location="+location;
		}
	});
	//级联
    $("#bankCountry").change(function(){
   	 var bankCountry = $("#bankCountry").val();
   	 var url = "${ctx}/getprovince.action";
   	 $.ajax({
			type:'POST',
			url:url,
			data: "countryId="+bankCountry,
			dataType:"html",
			success: function(data,status){
				if($.trim(data)!=''){
					$("#bankProvince").html(data);
				}
			},
			error: function(data,status,e){
				alert(e.name);
			}
		});
    });
	

});

function doSave(){
	$.ajaxSetup({cache:false});
	var checkFlg = true;
	checkFlg = checkFlg && validateEmpty_jquery("推荐人", "recommendId");
	checkFlg = checkFlg && validateEmpty_jquery("安置人", "parentId"); //判断安置人是否已满 
	//checkFlg = checkFlg && false;
	$.ajax({
		type:'POST',
		url: "${ctx}/checkloc.action",
		data: "user.parentId="+$("#parentId").val()+"&user.location="+$("#location").val()+"&user.recommendId="+$("#recommendId").val(),
		dataType:"html",
        async:false,  // 设置同步方式
        cache:false,
		success: function(data,status){
			if($.trim(data)!=''){
				alert(data);
				checkFlg = false;
			}
		},
		error: function(data,status,e){
			alert(e.name);
		}
	});
	checkFlg = checkFlg && validateEmpty_jquery("登录密码", "firstPwd");
	checkFlg = checkFlg && validateEmpty_jquery("确认登录密码", "firstPwd2");
	//alert($("#firstPwd").val()+"--"+$("#firstPwd2").val());
	if($("#firstPwd").val() != $("#firstPwd2").val()){
		setValidateErrorStyle_jquery($("#firstPwd"));
		setValidateErrorStyle_jquery($("#firstPwd2"));
		alert("两次输入的密码不相等");
	    checkFlg = false;
	}
	checkFlg = checkFlg && validateEmpty_jquery("二级密码", "secondPwd");
	checkFlg = checkFlg && validateEmpty_jquery("确认二级密码", "secondPwd2");
	if($("#secondPwd").val() != $("#secondPwd2").val()){
		setValidateErrorStyle_jquery($("#secondPwd"));
		setValidateErrorStyle_jquery($("#secondPwd2"));
	   alert("两次输入的密码不相等");
	   checkFlg = false;
	}
	checkFlg = checkFlg && validateEmpty_jquery("三级密码", "thirdPwd");
	checkFlg = checkFlg && validateEmpty_jquery("确认三级密码", "thirdPwd2");
	if($("#thirdPwd").val() != $("#thirdPwd2").val()){
		setValidateErrorStyle_jquery($("#thirdPwd"));
		setValidateErrorStyle_jquery($("#thirdPwd2"));
	   alert("两次输入的密码不相等");
	   checkFlg = false;
	}
	var bankRadio = $('input:radio[name="bankType"]:checked').val();
	if(bankRadio == "2"){ //自定义银行
		checkFlg = checkFlg && validateEmpty_jquery("自定义开户行", "bankName2");
	}
	checkFlg = checkFlg && validateEmpty_jquery("分支行", "subBranch");
	checkFlg = checkFlg && validateEmpty_jquery("国家", "bankCountry");
	checkFlg = checkFlg && validateEmpty_jquery("省市", "bankProvince");
	checkFlg = checkFlg && validateEmpty_jquery("户名", "bankUser");
	checkFlg = checkFlg && validateEmpty_jquery("银行账号", "bankCard");

	if ( !checkFlg ) return false;
    if (checkFlg) {
    	//var data = $("#othermember").formSerialize();
    	$("#other").removeAttr("onclick");
    	document.forms[0].action = "${ctx}/saveMember.action";
        document.forms[0].submit();
    }
}
</script>